package com.hzw.rest;

import com.hzw.api.IOrderService;
import com.hzw.entity.Order;
import com.hzw.entity.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
@CrossOrigin
@RequestMapping("order")
public class OrderController {

    @Autowired
    IOrderService orderService;

    /**
     * 新增订单
     *
     * @param orderVo
     * @return
     */
    @PostMapping("insert")
    @ResponseBody
    public int insert(@RequestBody OrderVo orderVo) {
        return orderService.insert(orderVo);
    }

    /**
     * 删除订单
     *
     * @param order
     * @return
     */
    @PostMapping("delete")
    @ResponseBody
    public void delete(@RequestBody Order order) {
        orderService.delete(order);
    }

    /**
     * 更新订单信息
     * @param order
     */
    @PostMapping("update")
    @ResponseBody
    public void update(@RequestBody Order order) {
        orderService.update(order);
    }

    /**
     * 查询订单信息
     * @param order
     */
    @PostMapping("select")
    @ResponseBody
    public List<Map<String, Object>> select(@RequestBody Order order) {
        return orderService.select(order);
    }
}
